import { ResPage, Tree, pageResData } from "@/api/interface/index";
import { PORT1, TreePort } from "@/api/config/servicePort";
import http from "@/api";

/**
 * @name 用户管理模块
 */
// 获取区域列表
export const getSpecList = (params: Tree.ReqRecordParams) => {
  console.log(params, "params");
  return http.post<ResPage<Tree.ResRecordList>>(TreePort + `/donate-record/pageList`, {
    page: params.page,
    pageSize: params.pageSize,
    search_key: {
      name: params.name,
      contact_information: params.contact_information,
      out_trade_no: params.out_trade_no,
      prepay_id: params.prepay_id,
      donate_amount: params.donate_amount,
      donate_number: params.donate_number,
      donate_total: params.donate_total,
      pay_status: params.pay_status,
      planting_area_name: params.planting_area_name,
      planting_tree_name: params.planting_tree_name,
      planting_tree_specification_name: params.planting_tree_specification_name,
      type: params.type,
      openid_mp: params.openid_mp,
      donate_at: params.donate_at,
      pay_at: params.pay_at,
      created_at: params.created_at,
      updated_at: params.updated_at
    }
  });
};

// 获取规格列表
export const getSpecList2 = (params: Tree.ReqRecordParams) => {
  return http.post<pageResData<Tree.ResSpecList>>(TreePort + `/planting-tree-specification/pageList`, params);
};

// // 获取树形用户列表
// export const getUserTreeList = (params: Tree.Req) => {
//   return http.post<ResPage<Tree.ResAreaList>>(PORT1 + `/Tree/tree/list`, params);
// };

// 新增用户
// export const addUser = (params: { id: string }) => {
//   return http.post(PORT1 + `/Tree/add`, params);
// };

// 新增区域
export const addSpec = (params: { id: string }) => {
  return http.post(TreePort + `/planting-tree-specification/add`, params);
};
// 批量添加用户
export const BatchAddUser = (params: FormData) => {
  return http.post(PORT1 + `/Tree/import`, params);
};

// 编辑用户
// export const editUser = (params: { id: string }) => {
//   return http.post(PORT1 + `/Tree/edit`, params);
// };

// 编辑区域
export const editSpec = (params: { id: string }) => {
  return http.post(TreePort + `/planting-tree-specification/update`, params);
};

// 删除用户
export const deleteUser = (params: { id: string[] }) => {
  return http.post(PORT1 + `/Tree/delete`, params);
};
// 删除区域
export const deleteSpec = (params: { id: string[] }) => {
  return http.post(TreePort + `/planting-tree-specification/delete`, params);
};
